<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
	require_once("database.php");
	require_once("facebook_include1.php");
	?>
<?php
    require_once("./config.php");
    $me = $facebook->api('/me');
    $access_token = $facebook->getAccessToken();
    $user = $facebook->getUser();
	
	
?>
<?php
	function check_input($data, $problem='')
	{
		$data = trim($data);
		$data = stripslashes($data);
		$data = htmlspecialchars($data);
		if ($problem && strlen($data) == 0)
		{
			die($problem);
		}
		return $data;
	}
	
	function check_required()
	{
	global $addr1,$city,$state,$zip,$country ,$addr2,$payment,$paypalId;
	$addr1 = check_input($_POST['addr1'], "Enter your address");
	
	$city = check_input($_POST['city'], "Enter your city");
	
	$state = check_input($_POST['state'], "Enter your state");
	
	$zip = check_input($_POST['zip'], "Enter your zip");
	
	$country = check_input($_POST['country'], "Please refresh the page and Enter your country");
	
	$addr2 =check_input($_POST['addr2']);
	
	$payment=$_POST['payment'];
	$paypalId=check_input($_POST['paypalId'],"Please refresh the page and Enter a valid paypal id");
	if (preg_match("/\D/",$zip))
		{
			die("Please enter numbers only for zip code");
		}
	}

     check_required();
	
	  login($access_token);
	 if (strcmp ($payment,'paypal')!=0)
	 {
	 	$paypalId=0;
	 }
	 
	createUser($user_id, $userName ,$email , $payment , $paypalId, $addr1 , $addr2 , $city , $state  ,$country , $zip );
?>
<!--block_head-->
  <link link href="_/css/grids-min.css" rel="stylesheet" type="text/css" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  <link link href="_/css/v3.css" rel="stylesheet" type="text/css" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  <link link href="_/css/downloads.css" rel="stylesheet" type="text/css" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  <link href='https://fonts.googleapis.com/css?family=Exo:700,700italic|Average' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" type="text/css" href="_/css/mystyle.css">
  <script type="text/javascript" src="_/js/jquery-1.8.2.min.js"></script>
  <script type="text/javascript" src="_/js/myscript.js"></script>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

<!-- /Facebook -->

</head>
<body>
<?php
    require_once("config.php");
?>
    
    <script>
      FB.init({
        appId  : $app_id,
        frictionlessRequests: true
      });



      function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'Sign up for a chance to play the Online Token Sharing Game and get rewarded with real money. This is a field study conducted by researchers from University of Minnesota  conducting a field experiment on ...'
        }, requestCallback);
      }
      
      function requestCallback(response) {
        // Handle callback here
      }
    </script>
<div id="doc" style="width:700px; padding-left:0px; margin-left:0px"> 
	   <div id="bd">
	   		<div id="yui-main"> 
				<div class="yui-b">
					<div class="yui-g">
						<div class="pageHeading" style="padding:15px 10px 15px 0px;">Online Token Sharing  Game!!</div>
                        <br/>
                        <div class="sectionHeading">Registration Done </div>
						<div style="padding:0px 0px 15px 0px;">
							<p class="font4">Thanks for signing up. We will be contacting you within a week via email if you are chosen to play the game. Please look for a mail from the "Online Token Sharing Game Administrator." </p>
						</div>
						<div class="sectionHeading">Invite Friends</div>
						<div style="padding:0px 0px 15px 0px;">
							<p class="font4">You can invite your friends in two ways. <a href="javascript:sendRequestViaMultiFriendSelector();">Click here</a> to invite them through Facebook or you can copy/paste the following text into an email and send it to your friends</p>
							
							<p class="font4">Sign up for a chance to play the Online Token Sharing Game and get rewarded with real money. This is an approved field study conducted by researcher from University of Minnesota . If you want to play click on http://apps.facebook.com/jmj_testa/</p>
							<p class="font4">If you have any questions feel free to contact the researcher <a href="mailto:rbapna@umn.edu">rbapna@umn.edu</a>.</p>
						</div>
					</div>
				</div>
	   		</div> 
	   </div> 
	   <div id="test">
	   </div> 
</div>
</body>
<?php
	if (isset($_GET['state'])){
		//echo "Going to create users";
		$id = $_GET['id'];
		userStream($id);
  		//getPhotos($id);
  	}
 ?>

</html>
